/*
* Copyright (C) 2009-2011 - Roman Kalynchuk
*
* This file is part of REngine.
*
* REngine is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* REngine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with REngine.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __IVERTEXBUFER_H__
#define __IVERTEXBUFER_H__

#include "kernel/refcount.h"
#include "render/rendertypes.h"

namespace rengine3d {

	class IRenderDriver;

	class IVertexBuffer: public CRefCount {
	public:
		IVertexBuffer(IRenderDriver* renderDriver, uint flags, vbDrawType_t drawType, vbUsageType_t usageType, uint vertexNum, uint indexNum){
			m_renderDriver	= renderDriver;
			m_vertexFlags	= flags;
			m_drawType		= drawType;
			m_usageType		= usageType;
			m_numElements	= 0;
		};

		virtual ~IVertexBuffer(){};

		virtual void AddVertex(const CVec3& vertex, uint flags) = 0;
		virtual void AddColor(const CVec4& color, uint flags) = 0;
		virtual void AddIndex(uint index) = 0;

		virtual void Compile(uint flags) = 0;
		virtual void Transform(const CMat4& transformMatrix) = 0;

		virtual void Draw(vbDrawType_t drawType = vbDrawType_Default ) = 0;
		virtual void DrawIndices(uint* indices, uint count, vbDrawType_t drawType = vbDrawType_Default ) = 0;

		virtual void Bind(void) = 0;
		virtual void UnBind(void) = 0;

		virtual void SetVertexStates(uint flags) = 0;

		virtual float* GetArray(uint arrayType) = 0;
		virtual uint* GetIndexArray() = 0;

		virtual void SetNumElements(int num)	{ m_numElements = num;}
		virtual int GetNumElements(void)		{ return m_numElements;}

		virtual uint GetVertexNum(void) = 0;
		virtual uint GetIndexNum(void) = 0;
	protected:
		unsigned int	m_vertexFlags;
		vbDrawType_t	m_drawType;
		vbUsageType_t	m_usageType;
		int				m_numElements;
		IRenderDriver*	m_renderDriver;


	};
}

#endif
